package com.province.platform.core.assign;

import com.province.platform.common.utils.Configuration;

import java.util.Collections;
import java.util.List;
import java.util.Random;

/**
 * 随机分布
 */
public class RandomAssign extends AbstractAssign {
    public RandomAssign(Configuration configuration, int channelNumber, int taskGroupChannel) {
        super(configuration, channelNumber, taskGroupChannel);
    }

    @Override
    public void doAssign(List<Configuration> contentConfig, List<List<Configuration>> taskGroupConfigList, int taskGroupNumber) {
        // 随机打乱
        Collections.shuffle(contentConfig, new Random(System.currentTimeMillis()));

        for (int i = 0; i < contentConfig.size(); i++) {
            taskGroupConfigList.get(i % taskGroupNumber).add(contentConfig.get(i));
        }
    }
}
